<!--
 * @Author: your name
 * @Date: 2022-03-17 23:24:01
 * @LastEditTime: 2022-03-17 23:39:35
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \算法测试\day0906\script\this.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var a = 'w'
        let obj = {
            a: 'o',
            print: function () {
                console.log(this.a);
            },
            print2: () => {
                console.log(this.a);
            }
        }
        let p = obj.print;
        let p2 = obj.print2;
        obj.print();
        obj.print2();
        p();
        p2();
        let c = function(){
            //a = 'llll'
            console.log(a);
            console.log(this.a);
        }
        c();
        //普通函数，this永远指向它的调用者；箭头函数，this指向定义时的上下文
    </script>
</body>

</html>